package com.tourism.tourismGYM.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.tourism.tourismGYM.entity.TourismRm;
import com.tourism.tourismGYM.service.TourismRmService;
/**
 * 活动管理控制类
 * @author gym
 *
 */
@RestController
@RequestMapping(value = "/tourism/rm")
public class TourismRmController {
	@Autowired
	private TourismRmService tourismRmService;
	 /**
     * 分页查询
     * @return
     */
    @RequestMapping(value="/page", method=RequestMethod.GET)
    public ResponseEntity<Page<TourismRm>> page(@RequestParam Map<String, Object> condition){
		Page<TourismRm> page = tourismRmService.page(condition);
        return new ResponseEntity<Page<TourismRm>>(page,HttpStatus.OK);
    }
    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value="/delete/{id}",method=RequestMethod.DELETE)
    public boolean delete(@PathVariable String id) {
        Assert.isTrue(null != id && !id.isEmpty(), "id不能为空");
        return tourismRmService.delete(id);
    }
    /**
     * 添加
     * @param tourismRm
     * @return
     */
    @RequestMapping(value="/create",method= RequestMethod.POST)
    public TourismRm create(@RequestBody TourismRm tourismRm) {
        Assert.isTrue(tourismRm != null, "实体不能为空");
        return tourismRmService.create(tourismRm);
    }
}
